<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<table class="display" id="example">
    <thead>
    <tr>
        <th>选择</th>
        <th>姓名</th>
        <th>性别</th>
        <th>邮箱</th>
    </tr>
    </thead>
    <tbody>
    <s:if test="#request.users==null || #request.users.size==0">
        <tr class="gradeX">
            <td colspan="5">暂无数据</td>
        </tr>
    </s:if>
    <s:iterator value="#request.users" var="u" status="sta">
        <s:if test="sta.odd">
            <tr class="gradeX"></tr>
        </s:if>
        <s:else>
            <tr class="gradeC"></tr>
        </s:else>
        <td><input type="checkbox" name="check_user" value="${u.id}" uname="${u.employeeinfoBase.name}"/></td>
        <td>${u.employeeinfoBase.name}</td>
        <td>${u.employeeinfoBase.sex}</td>
        <td>${u.employeeinfoBase.email}</td>
        </tr>
    </s:iterator>
    </tbody>
</table>
<p>
    <%@ include file="/WEB-INF/pages/common/main_orgtab_pager.jsp" %>
</p>

<p align="center">
    <button class="button" type="button" onclick="selectUser()">确定</button>
    <button class="button" type="button" onclick="cancelUser()">取消</button>
</p>

<script type="text/javascript">
    function cancelUser(){
        closeWindown();
    }
    function selectUser(){

        //var obj = $("input:radio[name='check_user'][checked]");//单选时
        //onSelectUser($(obj).attr("value"), $(obj).attr("uname"));
        //多选时
        var a = new Array();
        $("input:checkbox[name='check_user'][checked]").each(function(){
            a.push(this.value+":"+$(this).attr("uname"));
        });
        if(a.length == 0){
            alert("没有选择用户")
            return;
        }
        onSelectUser("array", a);
        cancelUser();
    }
</script>